import util from '@/libs/util';
export default {
    name: 'exportable-table',
    data () {
        return {
            columns: [{
                title: '序号',
                key: 'rownum',
                align: 'center',
                width: 60,
                render: (h, params) => {
                    return h('div', {}, ((this.pageIndex - 1) * this.pageSize + params.index + 1));
                }
            }, {
                title: '姓名',
                key: 'name'
            }, {
                title: '性别',
                key: 'gender',
                render: (h, params) => {
                    let texts = '未知';
                    if (params.row.gender === 'MAN') {
                        texts = '男';
                    } else if (params.row.gender === 'WOMAN') {
                        texts = '女';
                    }
                    return h('div', {}, texts);
                }
            }, {
                title: '任职部门',
                key: 'orgname',
                render: (h, params) => {
                    return h('div', {}, (params.row.organize ? params.row.organize.name : ''));
                }
            }, {
                title: '学历',
                key: 'education',
                render: (h, params) => {
                    return h('div', {}, (params.row.education ? params.row.education.name : ''));
                }
            }, {
                title: '职称',
                key: 'technical',
                render: (h, params) => {
                    return h('div', {}, (params.row.technical ? params.row.technical.name : ''));
                }
            }, {
                title: '手机号',
                key: 'cellphone'
            }],
            data: [],
            query: {
                name: '',
                gender: '',
                education: '',
                technical: '',
                teachertype: ''
            },
            total: 0,
            pageIndex: 1,
            pageSize: 10
        };
    },
    mounted () {
        this.loadList();
    },
    methods: {
        loadList: function () {
            util.ajax.post('/busine/teacher/list', util.toFormData({
                page: this.pageIndex,
                size: this.pageSize,
                name: this.query.name,
                gender: (this.query.gender ? this.query.gender : ''),
                educationid: (this.query.educationid ? this.query.educationid : ''),
                teachertypeid: (this.query.teachertypeid ? this.query.teachertypeid : '')
            })).then(res => {
                this.data = res.data.data.list;
                this.total = res.data.data.total;
            });
        },
        refresh: function () {
            this.query = {
                name: '',
                gender: '',
                education: '',
                technical: '',
                teachertype: ''
            };
            this.loadList();
        }
    }
};
